<template>
	<Theme>
		<view class="py4 px6 bgw">
			<u-search @input="input" placeholder="请输入银行名搜索,如:大望路" :show-action="false" />
		</view>
		<List>
			<view class="p4 br2 mt4 bgw" @click="select(item.id, item.name)" v-for="(item,i) in list" :key="i">
				{{item.name}}
			</view>
		</List>
	</Theme>
</template>

<script lang="ts">
import util from '@/utils/util'
import {page,list} from '@/mixins'

export default {
	mixins: [page,list],
	data() {
		return {
			meta:{title:'银行选择'},
			pid: '',
			city_code: ''
		}
	},
	onLoad(querys) {
		this.pid = querys.pid
		this.city_code = querys.city_code
	},
	methods: {
		input (e) {
			const params = [['name', e, 'match_phrase']]
			params.push(['bank_code', this.pid, 'term'])
			// params.push(['city_code', this.city_code, 'term'])
			uni.$es.search('bank', params).then(res=>{
				this.list = res.list
			})
		},
		select(id, name){
			util.last(vm=>{
				vm.formData.bank_branch_id = id
				vm.formData.bank_name = name
			})
			uni.navigateBack()
		}
	}
}
</script>
